<?php
	if(!isset($_REQUEST['ajax'])){ $_REQUEST['ajax'] = "";}
	if($_REQUEST['ajax']!=true) include 'header.tpl.php';
	include 'task_panel.tpl.php';
?>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel">
				<div class="panel-heading">
					<div class="panel-title"><i class="icon-cog"></i> <?php echo $this->cTitle;?></div>
				</div>
				<div class="panel-body">
					<form action="javascript:taskFilter();" class="form-inline">
						<label><?php echo $this->language['search'];?> : </label>
						<input type="text" class="form-control" placeholder="<?php echo $this->language['title'];?>" id="search_tieude" name="tieude" value="<?php echo $_GET['tieude'];?>">
						<select name="nguoigiao" id="search_nguoigiao" class="form-control">
							<option value='0'>Tất cả người tạo</option>
							<?php foreach($_SESSION['room_data'] as $room):?>
							<optgroup label="<?php echo $room['room_name'];?>">
								<?php foreach($room['users'] as $user):?>
								<option value="<?php echo $user['user_id'];?>"><?php echo $user['user_fullname'];?></option>
								<?php endforeach;?>
							</optgroup>
							<?php endforeach;?>
						</select>
						<select name="nguoinhan" id="search_nguoinhan" class="form-control">
							<option value='0'>Tất cả người nhận</option>
							<?php foreach($_SESSION['room_data'] as $room):?>
							<optgroup label="<?php echo $room['room_name'];?>">
								<?php foreach($room['users'] as $user):?>
								<option value="<?php echo $user['user_id'];?>"><?php echo $user['user_fullname'];?></option>
								<?php endforeach;?>
							</optgroup>
							<?php endforeach;?>
						</select>
						<select class="form-control" id="statusFilter" name="status">
							<option value="all">Tất cả Tình trạng</option>
							<option value="0" <?php echo ($_GET['status'] == "0") ? "selected" : "";?>>Đang chờ</option>
							<option value="1" <?php echo ($_GET['status'] == 1) ? "selected" : "";?>>Đang xử lý</option>
							<option value="2" <?php echo ($_GET['status'] == 2) ? "selected" : "";?>>Báo cáo hoàn thành</option>
							<option value="3" <?php echo ($_GET['status'] == 3) ? "selected" : "";?>>Hoàn thành</option>
							<option value="5" <?php echo ($_GET['status'] == 5) ? "selected" : "";?>>Đã quá hạn</option>
							<option value="-1" <?php echo ($_GET['status'] == -1) ? "selected" : "";?>>Đã từ chối</option>
						</select>
						<button class="btn btn-danger" type="submit"><i class="icon-search"></i> <?php echo $this->language['search'];?></button>
					</form>
					<div class="clear"></div>
					<table class="table table-fixed table-hover table-condensed">
						<thead>
							<tr>
								<th width="60px"><?php echo $this->language['type'];?></th>
								<th width="auto"><?php echo $this->language['task_name'];?></th>
								<th width="100px"><?php echo $this->language['task_end_date'];?></th>
								<th width="112px"><?php echo $this->language['status'];?></th>
								<th width="120px"><?php echo $this->language['receiver'];?></th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($this->items as $row){ ?>
							<tr <?php echo $row['style_1'];?>>
								<td>
									<?php
									if($row['tType']>=1)
										echo "<a href='#project_view/pid={$row['pId']}' title='{$row['pName']}'>".$this->language['task_project_type']."</a>";
									else
										echo $this->language['task_request_type'];
									?>
								</td>
								<td <?php echo $row['style_2'];?>>
									<a href='#task_view/tid=<?php echo $row['tId'];?>' title='<?php echo $row['tTitle'];?>'><?php echo $row['tTitle'];?></a>
								</td>
								<td>
									<?php
									if(time()>$row['tDeadTime'] && $row['tStatus'] < 3 && $row['tStatus'] >= 0)
										echo "<font color=red>".date("d/m/Y",$row['tDeadTime'])."</font>";
									else
										echo date("d/m/Y",$row['tDeadTime']);
									?>
								</td>
								<td class="text-center">
									<?php
									if($row['tStatus']==0) echo "<span class='label label-waiting'>".$this->language['waiting']."</span>";
									elseif($row['tStatus']==1) echo "<span class='label label-process'>".$this->language['processing']."</span>";
									elseif($row['tStatus']==2) echo "<span class='label label-preview'>".$this->language['testing']."</span>";
									elseif($row['tStatus']==3) echo "<span class='label label-complete'>".$this->language['completed']."</span>";
									elseif($row['tStatus']==-1) echo "<span class='label label-deny'>".$this->language['cancelled']."</span>";
									else echo $this->language['unknown'];
									?>
								</td>
								<td>
									<?php echo $_SESSION['user_data'][$row['tCreateUser']]['fullname'];?>
								</td>
							</tr>
							<?php } ?>
						</tbody>
						<?php if(isset($this->tfoot)) echo $this->tfoot;?>
						<tfoot>
							<tr>
								<td colspan=5>
									<div class="bulk-actions align-left">
										<form action="javascript:;" class="form-inline">
											<select name="cv" id="cvdrop" class="form-control" onChange="taskFilter();">
												<option value="0"><?php echo $this->language['task_all_type'];?></option>
												<option value="1" <?php echo ($_GET['taskType'] == 1) ? "selected":"";?>><?php echo $this->language['task_project_type'];?></option>
												<option value="2" <?php echo ($_GET['taskType'] == 2) ? "selected":"";?>><?php echo $this->language['task_request_type'];?></option>
											</select>
										</form>
									</div>
									<?php if(isset($this->pagination)) echo $this->pagination;?>
								</td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="resources/scripts/jquery-ui.min.js"></script>
	<script type="text/javascript" src="resources/scripts/jquery.datePicker.js"></script>
	<script>
	$(function() {
		$( "#datepicker1" ).datepicker({dateFormat: 'dd-mm-yy'});
		$( "#datepicker" ).datepicker({dateFormat: 'dd-mm-yy'});
	});
	</script>
<?php if(isset($this->breadcrumb) && isset($this->title_header)):?>
	<script type="text/javascript">
		$(function() {
			$("#title-header").text('<?php echo $this->title_header;?>');
			$("#breadcrumb").html('<?php echo build_breadcrumb($this->breadcrumb);?>');
		});
	</script>
<?php endif;?>
<?php
	if($_REQUEST['ajax']!=true) include 'footer.tpl.php';
?>